/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package nhadat.action.form;


import nhadat.dao.NguoiDungDAO;
import nhadat.entity.TblNguoiDung;

/**
 *
 * @author phuchk60280
 */
public class RegisterActionForm extends org.apache.struts.action.ActionForm {
    private String tendangnhapdk;
    private String matkhaudk;
    private String xnmatkhaudk;
    private String ho;
    private String ten;
    private String email;
    private String diachi;
    private String dtnha;
    private String dtdd;
    private TblNguoiDung nguoidung;

    public String getXnmatkhaudk() {
        return xnmatkhaudk;
    }

    public void setXnmatkhaudk(String xnmatkhaudk) {
        this.xnmatkhaudk = xnmatkhaudk;
    }


    public String getMatkhaudk() {
        return matkhaudk;
    }

    public void setMatkhaudk(String matkhaudk) {
        this.matkhaudk = matkhaudk;
    }

    public String getTendangnhapdk() {
        return tendangnhapdk;
    }

    public void setTendangnhapdk(String tendangnhapdk) {
        this.tendangnhapdk = tendangnhapdk;
    }


    public String getDiachi() {
        return diachi;
    }

    public void setDiachi(String diachi) {
        this.diachi = diachi;
    }

    public String getDtdd() {
        return dtdd;
    }

    public void setDtdd(String dtdd) {
        this.dtdd = dtdd;
    }

    public String getDtnha() {
        return dtnha;
    }

    public void setDtnha(String dtnha) {
        this.dtnha = dtnha;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getHo() {
        return ho;
    }

    public void setHo(String ho) {
        this.ho = ho;
    }

    

    public String getTen() {
        return ten;
    }

    public void setTen(String ten) {
        this.ten = ten;
    }

    

    public TblNguoiDung getNguoidung() {
        return nguoidung;
    }

    public void setNguoidung(TblNguoiDung nguoidung) {
        this.nguoidung = nguoidung;
    }

    public RegisterActionForm() {
        this.nguoidung = null;
    }

    public RegisterActionForm(TblNguoiDung nguoidung) {
        this.nguoidung = nguoidung;
    }

    public RegisterActionForm(String tendangnhapdk, String matkhaudk, String xnmatkhaudk, String ho, String ten, String email, String diachi, String dtnha, String dtdd, TblNguoiDung nguoidung) {
        this.tendangnhapdk = tendangnhapdk;
        this.matkhaudk = matkhaudk;
        this.xnmatkhaudk = xnmatkhaudk;
        this.ho = ho;
        this.ten = ten;
        this.email = email;
        this.diachi = diachi;
        this.dtnha = dtnha;
        this.dtdd = dtdd;
        this.nguoidung = nguoidung;
    }

    

    
    public boolean registerUser(){
       NguoiDungDAO nguoiDungDAO = new NguoiDungDAO();
       boolean exist = nguoiDungDAO.checkUserExit(this.getTendangnhapdk());
       TblNguoiDung nguoidung = new TblNguoiDung();

        if (!exist) {
            nguoidung.setTendangnhap(this.getTendangnhapdk());
            nguoidung.setMatkhau(this.getMatkhaudk());
            nguoidung.setHo(this.getHo());
            nguoidung.setTen(this.getTen());
            nguoidung.setEmail(this.getEmail());
            nguoidung.setDiachi(this.getDiachi());
            nguoidung.setDienthoai(this.getDtnha());
            nguoidung.setDienthoaididong(this.getDtdd());

            nguoiDungDAO.insertUser(nguoidung);
            return true;

        }
        return false;
    }


}
